<?php
/**
 * Created by PhpStorm.
 * User: lullabies
 * Date: 2019/5/22
 * Time: 23:38
 */

namespace app\api\controller;
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept,fs-token");
header('Access-Control-Allow-Methods: GET, POST');
use app\api\model\ExamBanner as ExamBannerModel;
/**
 * @title 考试轮播图接口
 * @group app
 */
class ExamBanner extends  Base
{
    /**
     * @title 图片轮播
     * @url /api/exam_banner/ListBanner
     * @author 开发者
     * @method POST/GET
     * @description 默认显示最新添加的三张轮播图  可指定显示轮播图的个数
     * @param name:num type:int default:3 require:0 desc:显示个数
     * @return id:轮播图id
     * @return name:轮播图名称
     * @return description:轮播图简介
     * @return img:轮播图地址
     * @return create_time:轮播图的创建时间
     */
    public function listBanner(){
        //判断是否指定个数
        $num = input('num',3,'intval');
        $result = ExamBannerModel::listBanner($num);
        if($result->isEmpty()){
            $this->apiReturn(303,'未找到相关信息！');
        }else{
            $this->apiReturn(200,'获取轮播图成功',$result);
        }
    }

}